﻿using System;

namespace csharp接口练习
{

    public interface IRegistor 
    {
        void Register();
    }


    class Person:IRegistor
    {
        public string name;
        public Person(string name)
        {
            this.name = name;
        }

        public void Register()
        {
            Console.WriteLine("注册人物信息");
        }
    }


    class House : IRegistor
    {
        public void Register()
        {
            Console.WriteLine("注册房子信息");
        }
    }



    class Car : IRegistor
    {
        public void Register()
        {
            Console.WriteLine("注册车子信息");
        }
    }


    class Program
    {
        static void Main(string[] args)
        {



            #region 人口登记，汽车登记，房子登记，都需要有注册的方法
            Person p = new Person("小明");

            Car c = new Car();
            

            House h = new House();

            //用登记的接口数组
            IRegistor[] registors = new IRegistor[3] {p,c,h};
            for (int i = 0; i < registors.Length; i++) 
            {
                registors[i].Register();
            }

           


            #endregion
        }
    }
}
